<template>
    <div>
        <!-- 55555/ -->
        <el-dialog :title="myDialog.title" :visible.sync="myDialog.flag" width="60%">
            {{changedata}}
            <el-form :model="cate">
                <el-form-item label="分类名称" label-width="80px">
                    <el-input v-model="cate.roleName" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="活动区域" label-width="80px">
                    <el-cascader :options="options" :props="props" v-model="changedata"></el-cascader>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="myDialog.flag = false">取 消</el-button>
                <el-button type="primary" @click="add">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import { addCate } from '@/utils/categoryapi'
export default {
    props: {
        myDialog: Object,
        cate: Object,
        options:Array,
        props:Object,
        changedata:Array,
    },
    methods: {
        async add() {
            // alert('哈哈')
            if (this.myDialog.type == "add") {
                console.log(this.cate);
                if(this.changedata.length==0){
                    this.cate.cat_pid=0
                }else{
                    this.cate.cat_pid=this.changedata[this.changedata.length-1]
                }
                this.cate.cat_level = this.changedata.length;
                addCate(this.cate);
                this.$emit('getList');
                this.close();
            }
        },
        /* 关闭模态框 */
        close() {
            this.myDialog.flag = false;
        }
    }
}
</script>